package com.heima.feigns;

import com.heima.config.HeimaFeignAutoConfiguration;
import com.heima.feigns.fallback.AryicleFeignFallback;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.search.vos.SearchArticleVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(
        value = "leadnews-article",
        fallbackFactory = AryicleFeignFallback.class,
        configuration = HeimaFeignAutoConfiguration.class
)
public interface ApAuthorFeign {

    @ApiOperation("根据id查询作者")
    @GetMapping("/api/v1/author/findByUserId/{id}")
    public ResponseResult<ApAuthor> findByUserId(@PathVariable("id") Integer id);

    @ApiOperation("根据id添加作者")
    @PostMapping("/api/v1/author/save")
    public ResponseResult<ApAuthor> save(@RequestBody ApAuthor author);


    @GetMapping("/api/v1/author/get/{id}")
    public ResponseResult<ApArticle> get(@PathVariable("id")Long id);


    @GetMapping("/api/v1/article/{id}")
    ResponseResult<SearchArticleVO> findArticle(@PathVariable("id") Long id);

}
